import { h, init } from "snabbdom";

let patch = init([]);
let app = document.querySelector("#app");

let vnode = h("div#container", [h("h1", "h1h1h1"), h("p", "ppppppp")]);

// 把真实dom转虚拟dom 并对比 进行渲染
let oldVnode = patch(app, vnode);

// 比较虚拟dom 差异 渲染页面
patch(oldVnode, vnode);
setInterval(() => {
  console.log("setInterval");
  let vdom = [
    h("h1", new Date().getTime()),
    h("h2", new Date().getTime()),
    h("p", "ppppppp"),
  ];
  oldVnode = patch(oldVnode, h("div#container", vdom));
}, 1000);
